<template>
	<view class="login" :style="{background:API_URL()+'images/pages-veriFace/login_back.png'}">
		<view class="login_tit">
			<view class="">
				<h3>深圳信息职业技术学院</h3>
				<h5>学生照片录入系统</h5>
			</view>

		</view>
		<view class="login_box">
			<view class="login_box_form">
				<view class="login_box_form_item">
					<view class="login_box_form_item_tit">
						学生姓名
					</view>
					<u-input v-model="form.realname" type="text" height="90" :border="true" clearable />
				</view>
				<view class="login_box_form_item">
					<view class="login_box_form_item_tit">
						学籍号
					</view>
					<u-input v-model="form.roll " type="number" height="90" :border="true" clearable />
				</view>
				<view class="login_box_form_btn" @click="login">
					登录
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import {
    API_URL
} from '@/env'
	export default {
		data() {
			return {
				form: {
					realname: '',
					roll: ''
				}
			}
		},
		methods: {
            API_URL() {
                return API_URL
            },
			async login() {
				let that = this;

				// return
				that
					.$http(
						"veriFace.login", {
							type: '3',
							roll: that.form.roll,
							realname: that.form.realname
						},
						"登录中..."
					)
					.then(res => {
						console.log(res)
						if (res.code == 0) {
							uni.setStorageSync('token', res.data.access_token)
							uni.setStorageSync('roll', that.form.roll)
							uni.setStorageSync('realname', that.form.realname)
							that.$u.toast(res.msg);
							setTimeout(function() {
								uni.navigateTo({
									url: './info'
								})
							}, 500)

						} else {
							that.$u.toast(res.msg);
						}
					});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.login {
		display: flex;
		height: 100vh;
		flex-direction: column;
		background-size: 100% 100%;
		background-repeat: no-repeat;

		&_tit {
			font-size: 48rpx;
			flex: .5;
			display: flex;
			flex-direction: column;
			justify-content: center;

			view {
				margin: auto;
			}
		}

		&_box {
			background: #F2F4FF;
			border-top-right-radius: 30rpx;
			border-top-left-radius: 30rpx;
			flex: 1;
			padding: 80rpx;
			box-sizing: border-box;



			.u-input--border {
				border: none !important;
				background: #fff;
				border-radius: 50px;
				padding: 0 40rpx !important;
				box-shadow: 0 0 1px rgba(54, 114, 250, .1)
			}

			.u-input__input {
				height: 80rpx;
			}

			&_form {
				&_item {
					margin-bottom: 30rpx;

					&_tit {
						margin-bottom: 20rpx;
						font-weight: bold;
						font-size: 30rpx;
					}
				}

				&_btn {
					margin-top: 100rpx;
					color: #FFFFFF;
					background: #1989F9;
					border-radius: 10px;
					padding: 20rpx 30rpx;
					font-size: 30rpx;
					text-align: center;
				}
			}
		}
	}
</style>
